import React from 'react'

import Constants from '../../common/Constants'
import BaseAction from '../common/BaseAction'

export default class HeartLoveRquestOtherDataAction extends BaseAction {
  constructor(props) {
    super(props)

    this.moduleType = Constants.MODULE_TYPE.HEART
    this.name = 'HeartLoveRquestOtherDataAction'
  }

  _dealCall(caller, data) {
    caller.setState({
      viewStatus: 2
    })
  }

  finish(data, isSucceed, response) {
    console.log('HeartLoveRquestOtherDataAction', data, isSucceed, response)
    if (isSucceed) {
      data.beenUpdated = false
      this.caller.setState({
        viewStatus: 3,
        loveData: data.links.lover,
        is_liked: data.is_liked == 1,
        isResponeUpdate: true,
        loadComplete: true
      })
    } else if (response) {
      if (response.status === 401) {
        this._dealUnauthorized(this.caller)
      } else {
        this.caller.setState({ viewStatus: response.status })
      }
    } else if (data.status === 404) {
      this.caller.setState({
        viewStatus: data.status,
        loadComplete: true,
        loveData: {}
      })
    }
  }
}
